﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Composition;
using Core.Common;
using Core.Interfaces;
using Core.DataAccess;
using Core.DataAccess.IRepositories;
using Core.BusinessLogic.Interfaces;

namespace Core.BusinessLogic
{
    [Export(typeof(ISchoolService))]
    public class SchoolService : ISchoolService
    {
        [Import]
        private IAccountRepository _accountRepository;
        [Import]
        private ISchoolRepository _schoolRepository;

        public SchoolService()
        {
            MEFManager.Compose(this);
        }

        public void SaveSchool(School school)
        {
            _schoolRepository.SaveSchool(school);
        }

        public void SaveAccountSchool(AccountSchool accSch)
        {
            _schoolRepository.SaveAccountSchool(accSch);
        }

        public List<School> GetSchoolsByAccountID(Int32 accountID)
        {
            return _schoolRepository.GetSchoolsByAccountID(accountID);
        }

        public School GetSchoolBySchoolID(Int32 schoolID)
        {
            return _schoolRepository.GetSchoolBySchoolID(schoolID);
        }

        public School GetSchoolBySchoolName(string schoolName)
        {
            return _schoolRepository.GetSchoolBySchoolName(schoolName);
        }

        public List<AccountSchool> GetAccountSchoolListByUsername(string username)
        {
            return _schoolRepository.GetAccountSchoolListByUsername(username);
        }

        public List<AccountSchool> GetAccountSchoolListByAccountID(Int32 accountID)
        {
            return _schoolRepository.GetAccountSchoolListByAccountID(accountID);
        }

        public List<Account> GetAllFriendsSchoolByAccountID(int accountID, string schoolName)
        {
            return _schoolRepository.GetAllFriendsSchoolByAccountID(accountID, schoolName);
        }

        public int UpdateSchoolInfo(int accountID, School school)
        {
            return _schoolRepository.UpdateSchoolInfo(accountID, school);
        }

        public int UpdateAccountSchoolInfo(int accountID, AccountSchool accSchool,int schoolID)
        {
            return _schoolRepository.UpdateAccountSchoolInfo(accountID, accSchool,schoolID);
        }
    }
}
